﻿#pragma once
#include "yzrutil.h"
#include "soundbank/Instrument.h"
#include "SF2InstrumentRegion.h"
#include "SF2GlobalRegion.h"
#include "collection/ArrayList.hpp"

namespace yzrilyzr_soundbank{
	class SF2Soundbank;
	ECLASS(SF2Instrument, public Instrument){
		yzrilyzr_collection::ArrayList<std::shared_ptr<SF2InstrumentRegion>> regions;
		int64_t library=0;
		int64_t genre=0;
		int64_t morphology=0;
		std::shared_ptr<SF2GlobalRegion> globalregion;
		public:
		SF2Instrument(SF2Soundbank * soundbank) : SF2Instrument(soundbank, ""){}
		SF2Instrument(SF2Soundbank * soundbank, const yzrilyzr_lang::String & name) : Instrument((Soundbank *)soundbank, name){}

		yzrilyzr_lang::String getName()const override{
			return name;
		}
		void setName(const yzrilyzr_lang::String & name){
			this->name=name;
		}
		int64_t getGenre(){
			return genre;
		}
		void setGenre(int64_t genre){
			this->genre=genre;
		}
		int64_t getLibrary(){
			return library;
		}
		void setLibrary(int64_t library){
			this->library=library;
		}
		int64_t getMorphology(){
			return morphology;
		}
		void setMorphology(int64_t morphology){
			this->morphology=morphology;
		}
		yzrilyzr_collection::ArrayList<std::shared_ptr<SF2InstrumentRegion>> & getRegions(){
			return regions;
		}
		std::shared_ptr<SF2GlobalRegion> getGlobalRegion(){
			return globalregion;
		}
		void setGlobalZone(std::shared_ptr<SF2GlobalRegion> zone){
			globalregion=zone;
		}
		yzrilyzr_lang::String toString() const override{
			if(bank == 128)
				return yzrilyzr_lang::String("Drumkit: ") + name + " preset #" + std::to_string(preset);
			else
				return yzrilyzr_lang::String("Instrument: ") + name + " bank #" + std::to_string(bank) + " preset #" + std::to_string(preset);
		}
	};
}
